package cn.itrip.order.service;

import cn.itrip.vo.ItripImageVO;
import cn.itrip.vo.ItripLabelDicVO;
import cn.itrip.dao.ItripHotelRoomMapper;
import cn.itrip.dao.ItripImageMapper;
import cn.itrip.dao.ItripLabelDicMapper;
import cn.itrip.pojo.ItripHotelRoom;
import cn.itrip.pojo.ItripImage;
import cn.itrip.pojo.ItripLabelDic;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by LENOVO on 2018/8/26.
 */
@Service
public class HotelRoomServiceImpl implements HotelRoomService {

    @Resource
    private ItripHotelRoomMapper itripHotelRoomMapper;
    @Resource
    private ItripImageMapper itripImageMapper;
    @Resource
    private ItripLabelDicMapper itripLabelDicMapper;
    /**
     * 根据条件查询酒店房间信息
     * @param condition
     * @return
     */
    @Override
    public List<ItripHotelRoom> HotelRoombyHotel(Map condition) throws Exception {

        return itripHotelRoomMapper.getHotelRoomListByCondition(condition);
    }
    /**
     * 根据targetId查找房间图片
     * @param condition
     * @return
     */
    @Override
    public List<ItripImageVO> getImageListByByTargetId(Map condition) throws Exception {

        List<ItripImageVO> itripImageInfoList=new ArrayList<>();
        List<ItripImage> itripImageList=itripImageMapper.getImageListByByTargetId(condition);
        for(int i=0;i< itripImageList.size();i++)
        {
            ItripImageVO itripImageInfo=new ItripImageVO();
            itripImageInfo.setImgUrl(itripImageList.get(i).getImgurl());
            itripImageInfo.setPosition(itripImageList.get(i).getPosition());
            itripImageInfoList.add(itripImageInfo);
        }
        return itripImageInfoList;
    }

    /**
     * 获取酒店床型
     * @param parentId
     * @return
     * @throws Exception
     */
    @Override
    public List<ItripLabelDicVO> getHotelRoomBedByParentId(Long parentId) throws Exception {

        List<ItripLabelDicVO> itripLabelDicInfoList=new ArrayList<>();
        List<ItripLabelDic> itripLabelDicList=itripLabelDicMapper.getHotelRoomBedByParentId(parentId);
        for(int i=0;i< itripLabelDicList.size();i++)
        {
            ItripLabelDicVO itripLabelDicInfo=new ItripLabelDicVO();
            itripLabelDicInfo.setId(itripLabelDicList.get(i).getId());
            itripLabelDicInfo.setDescription(itripLabelDicList.get(i).getDescription());
            itripLabelDicInfo.setName(itripLabelDicList.get(i).getName());
            itripLabelDicInfo.setPic(itripLabelDicList.get(i).getPic());
            itripLabelDicInfoList.add(itripLabelDicInfo);
        }
        return itripLabelDicInfoList;

    }
}
